using Microsoft.AspNetCore.Mvc;
using Sheep_Breeding.ErrorCode;
using Sheep_Breeding.Write.Api.DTOSheep;
using Sheep_Breeding.Write.Api.OperationServices.IServices;

namespace Sheep_Breeding.Write.Api.Controllers
{
    /// <summary>
    /// 期初管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PhaseBeginController : ControllerBase
    {
        private readonly ILogger<PhaseBeginController> logger;
        private readonly IPhaseBeginServices phaseBeginServices;

        public PhaseBeginController(ILogger<PhaseBeginController> logger, IPhaseBeginServices phaseBeginServices)
        {
            this.logger = logger;
            this.phaseBeginServices = phaseBeginServices;
        }

        /// <summary>
        /// 批量新增期初信息
        /// </summary>
        /// <param name="dtoList"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> AddPhaseBegin(List<CreatePhaseBeginDTo> dtoList)
        {
            try
            {
                return await phaseBeginServices.AddPhaseBegin(dtoList);
            }
            catch (Exception ex)
            {
                logger.LogError("=>" + ex.Message);
                throw ex;
            }
        }
    }
} 